// // ******************************************************************
// //       /\ /|       @file       TranslationServicesQueryHandler.cs
// //       \ V/        @brief      await29
// //       | "")       @author     Await, 285283010@qq.com
// //       /  |
// //      /  \\        @Modified   2025-02-01 10:02
// //    *(__\_\        @Copyright  Copyright (c) , 2025-01-29 21:01 Await
// // ******************************************************************

using AutomaticSubtitles.Contracts.Services;
using AutomaticSubtitles.Service.Application.Cahce.Queries;
using AutomaticSubtitles.Service.Application.Translate.Queries;
using AutomaticSubtitles.Service.Application.Translate.Service.Queries;
using AutomaticSubtitles.Service.Domain.Media;
using AutomaticSubtitles.Service.Infrastructure.BaiduTrans;
using AutomaticSubtitles.Service.Infrastructure.BaiduTrans.Model;

namespace AutomaticSubtitles.Service.Application.Translate.Service;

public class TranslationServicesQueryHandler : BaseAutoService
{
    private readonly ISubtitleRepository _repository;
    private readonly ITranslationService _translationService;

    public TranslationServicesQueryHandler(ISubtitleRepository repository, ITranslationService translationService)
    {
        _repository = repository;
        _translationService = translationService;
    }

    [EventHandler]
    public async Task Handle(GetSubtitleDataQuery query)
    {
        var subtitle = await _repository.GetListAsync(x => query.media.Contains(x.VideoId));
        query.Result = subtitle.ToList();
    }
}